<?php

namespace Cpadmin\Model;

class Admin {

    private $adminId;
    private $adminUsername;
    private $adminpassword;
    private $adminActive;

    public function exchangeArray($data) {
        $this->adminId = (isset($data["adminId"])) ? $data["adminId"] : null;
        $this->adminUsername = (isset($data["adminUsername"])) ? $data["adminUsername"] : null;
        $this->adminpassword = (isset($data["adminpassword"])) ? $data["adminpassword"] : null;
        $this->adminActive = (isset($data["adminActive"])) ? $data["adminActive"] : null;
    }

    public function setAdminUsername($value) {
        $this->adminUsername = $value;
    }

    public function getAdminUsername() {
        return $this->adminUsername;
    }

    public function getAdminPassword() {
        return $this->adminpassword;
    }

    public function getAdminActive() {
        return $this->adminActive;
    }

    public function setAdminpassword($value) {
        $this->adminpassword = $value;
    }

    public function setAdminActive($value) {
        $this->adminActive = $value;
    }

    public function __set($nameSet, $valueSet) {
        $getfunction = "set" . $nameSet;
        return $this->$getfunction($valueSet);
    }

    public function __get($nameGet) {
        $getFunction = "get" . $nameGet;
        return $this->$getFunction($nameGet);
    }

    public function setPassword($passinput) {
        $pass = md5($passinput);
        $passbase = str_replace("=", "", base64_encode($pass));
        $hashAndSalt = password_hash($passbase, PASSWORD_BCRYPT);
        return $hashAndSalt;
    }

    public function getPassword($passinput,$check) {
        $pass = md5($passinput);
        $passbase = str_replace("=", "", base64_encode($pass));
        if (password_verify($passbase, $check)) {
            return "data";
        } else {
           return "";
        }
    }

}
